﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Reflection;

namespace Blazing.Web.Util
{
    public class WidgetParameters
    {
        public static void SetParameters(Control ctrl, string parameterString)
        {
            string[] param = parameterString.Split(';');
            foreach (string p in param)
            {
                string[] values = p.Split('=');
                setPropertyValue(ctrl, values[0], values[1]);
            }
        }

        static void setPropertyValue(Control ctrl, string propertyName, string propertyValue)
        {
            PropertyInfo info = ctrl.GetType().GetProperty(propertyName);
            info.SetValue(ctrl, Convert.ChangeType(propertyValue, info.PropertyType), null);
        }
    }
}
